package com.xiaoankang.controller;


import com.xiaoankang.domain.Student;
import com.xiaoankang.service.StudentService;
import com.xiaoankang.util.Result;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

/*
   @PutMapping  查询 get提交  删除 delete  修改 PUT提交  添加 post提交
    //关于:CRUD 增删改
    @PutMapping("update")
    public Result update(@RequestBody Emp emp){
        System.out.println(emp);
        return null;
    }
}
* */
@RestController
public class StudentController {
    @Autowired
    private StudentService studentService;

    @GetMapping("findAll")
    public Result findAll(){
        return studentService.queryAll();
    }

    @GetMapping("findById/{id}")
    public Result findById(@PathVariable Integer id){
        return studentService.queryById(id);
    }
    @PostMapping("insert")
    public int insert(@RequestBody Student student){
        return studentService.insert(student);
    }
    @DeleteMapping("deleteById/{id}")
    public int deleteById(@PathVariable Integer id){
        return studentService.deleteById(id);
    }
    @PutMapping("updateIdInt")
    public Result updateIdInt( @RequestBody Student student){
        return studentService.updateIdInt(student);
    }
}
